package file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

//https://blog.csdn.net/qq_51372098/article/details/113408678
public class FIleOperate {
    public static void main(String[] args) {
//        File file = new File();
        System.out.println("===========");
//        System.out.println(System.getProperty("PATH"));
//        System.out.println(System.getProperty("user.home"));
        String userPath = System.getProperty("user.home");
        try {
            File file = new File(userPath, "/check.txt");
            System.out.println(file.exists() + "");
            FileInputStream fileInputStream = new FileInputStream(file);
            System.out.println(fileInputStream.read());
            InputStreamReader inputStreamReader=new InputStreamReader(fileInputStream,"UTF-8");
            BufferedReader bufferedReader=new BufferedReader(inputStreamReader);


            String line;
            while ((line = bufferedReader.readLine()) != null) {
                System.out.println(line);
            }


//            int data;
//            while ((data=fileInputStream.read()) != -1) {
//                System.out.println((char)data);
//            }

        } catch (Exception e) {
            e.printStackTrace();
        }
//        System.out.println(userPath);
//        try {
//            System.out.println(System.getProperty("user.dir"));
//            String rootPath = System.getProperty("user.dir");
//            System.out.println(rootPath);
//            File file = new File("file1.txt");
//            System.out.println(file.getAbsolutePath());
//            if (!file.exists()) {
//                file.createNewFile();
//            }
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }


}
